package com.hsteach.web.controller.myopia;

import com.hsteach.common.core.controller.BaseController;
import com.hsteach.common.core.domain.AjaxResult;
import com.hsteach.common.core.page.TableDataInfo;
import com.hsteach.dao.domain.myopia.MyopiaMission;
import com.hsteach.dao.domain.myopia.MyopiaSchoolMission;
import com.hsteach.service.myopia.MyopiaMissionService;
import com.hsteach.web.controller.myopia.dto.MissionListDTO;
import com.hsteach.web.controller.myopia.dto.MyopiaMissionInfoDTO;
import com.hsteach.web.controller.myopia.vo.MyopiaSchoolMissionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 近视管理任务Controller
 *
 * @author lx
 * @date 2023-07-07
 */
@Api(value = "近视管理任务", tags = "近视管理任务")
@RestController
@RequestMapping("/myopia/mission")
public class MyopiaMissionController extends BaseController {

    @Autowired
    private MyopiaMissionService missionService;

    /**
     * 新增近视管理任务
     */
    @ApiOperation("新增近视管理任务")
    @PostMapping()
    public AjaxResult add(@Validated @RequestBody MyopiaMission mission) {
        missionService.add(mission);
        return success();
    }


    /**
     * 获取近视管理任务列表
     */
    @ApiOperation("获取近视管理任务列表")
    @GetMapping("/list")
    public TableDataInfo<MyopiaMission> list(@Validated MissionListDTO dto) {
        startPage();
        return getDataTable(missionService.getList(dto));
    }

    /**
     * 学校获取近视管理任务列表
     */
    @ApiOperation("学校获取近视管理任务列表")
    @GetMapping("/schoolList")
    public TableDataInfo<MyopiaSchoolMissionVO> schoolList(@Validated MissionListDTO dto) {
        startPage();
        return getDataTable(missionService.schoolList(dto));
    }

    /**
     * 获取近视管理任务详情
     */
    @ApiOperation("获取近视管理任务详情")
    @GetMapping("/info")
    public TableDataInfo<MyopiaSchoolMission> info(@Validated MyopiaMissionInfoDTO dto) {

        return getDataTable(missionService.getInfo(dto));
    }

    /**
     * 批量删除近视管理任务
     */
    @ApiOperation("批量删除近视管理任务")
    @DeleteMapping("/{ids}")
    public AjaxResult batchDel(@PathVariable Long[] ids) {
        missionService.batchDel(ids);
        return success();
    }

}
